<?php

$tmp = 'xml_rpc.class.phps';
include_once($tmp);

if(!defined('XMLRPC_DEBUG'))
	define('XMLRPC_DEBUG', 1);

//log in and get session id
$data = array('username' => 'admin', 'domain' => 'domain.com', 'password' => 'p@ssw0rd');
list($success, $session) = XMLRPC_request('localhost:81', '/rpc.php', 'system.login', array(XMLRPC_prepare($data)));
if(!$success) {
	echo 'Coulnd\'t login: '.$session['faultString']."\n";
//	return;
}

//create a new domain and user using cascadecall
$data = array(
	//Load defaults from existing domain ;)
	array(
		'domain.domaininfo',
		array()
	),
	array(
		'reseller.newdomain',
		array(
			array(
				'domain' => 'example'.mt_rand().'.com',
				'defaultroot' => '/www/web/',
			)
		)
	),
	array(
		//make sure the domain has actually been created, or the next call will fail
		'system.wait',
		array()
	),
	array(
		'domain.newuser',
		array(
			array(
				'name' => 'Example User',
				'username' => 'u'.mt_rand(),
				'password' => 'p@ssw0rd',
				'root' => '/',
				'type' => 'standard',
				'level' => USER_LEVEL_DOMAIN,
				'hd' => 10,
			)
		)
	)
);
list($success, $response) = XMLRPC_request('localhost:81', '/rpc.php', 'system.cascadecall', array($session, XMLRPC_prepare($data)));
if(!$success) {
	// todo
}


XMLRPC_debug_print();

?>